package offer;

import java.util.*;

public class offer50 {
}
class Solution50 {
    public static char firstUniqChar(String s) {
        if(s.length()==0)
        {
            return ' ';
        }
        char[] c = s.toCharArray();
        Map<Character, List> map = new LinkedHashMap<>();
        for (int i = 0; i < c.length; i++) {
             if(!map.containsKey(c[i]))
             {
                map.put(c[i],new ArrayList());
             }else {
                 map.get(c[i]).add(c[i]);
             }

        }
        Set entries = map.entrySet();
        char key = ' ';
        for(Object obj:entries)
        {
            Map.Entry entry = (Map.Entry) obj;
            if(((List)entry.getValue()).size()==0) {
                key = (Character) entry.getKey();
                break;
            }
        }
        return key;
    }

    public static void main(String[] args) {
       String s = "abaccdeff";
        char c = firstUniqChar(s);
    }
}